dnl Process this file with autoconf to produce a configure script.
AC_INIT(buffer.c)

AC_CONFIG_HEADER(config.h)

dnl Checks for compiler
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
AC_PROG_LN_S

dnl Check for Systems
AC_AIX
AC_ISC_POSIX
AC_MINIX
AC_CANONICAL_SYSTEM

dnl Check for configuration options
dnl Enable OS/2 extended density format disks
undefine([xdf])dnl
AC_ARG_ENABLE(xdf,
[  --enable-xdf           support for OS/2 extended density format disks],
[if test x$enableval = xyes; then
  AC_DEFINE(USE_XDF)
fi],AC_DEFINE(USE_XDF))


dnl Check for configuration options
dnl Enable OS/2 extended density format disks
undefine([xdf])dnl
AC_ARG_ENABLE(vold,
[  --enable-vold          compatibility with Solaris' vold],
[if test x$enableval = xyes; then
  AC_DEFINE(USING_VOLD)
fi])

dnl Checks for libraries.

dnl AC_IRIX_SUN
AC_CHECK_LIB(sun, getpwnam)

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(getopt.h sys/stat.h stdlib.h unistd.h \
fcntl.h limits.h sys/file.h sys/ioctl.h sys/time.h strings.h string.h \
sys/param.h memory.h malloc.h sys/signal.h utime.h getopt)
AC_CHECK_HEADERS(termios.h sys/termios.h termio.h sys/termio.h, [break])

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(strerror random srandom strchr strrchr lockf flock \
strcasecmp strncasecmp \
strdup strcspn strspn strtoul memcpy strpbrk memset)

AC_CHECK_FUNCS(utime utimes, [break])
AC_CHECK_FUNCS(gettimeofday tzset, [break])

[
host_os1=`echo $host_os | sed 's/\./_/g'`
host_os2=`echo $host_os | sed 's/^\([^.]*\)\..*$/\1/g'`
host_os3=`echo $host_os2 | sed 's/^\([^0-9]*\)[0-9]*$/\1/g'`
HOST_ID="-D$host_cpu -D$host_os1"
if [ $host_os1 != $host_os2 ] ; then
	HOST_ID="$HOST_ID -D$host_os2"
fi
if [ $host_os1 != $host_os3 ] && [ $host_os2 != $host_os3 ] ; then
	HOST_ID="$HOST_ID -D$host_os3"
fi

my_host_os=`echo $host_os1 $host_os2 $host_os3 | sort -u`
objs=`echo $srcdir/*.c | sed 's/\.c$/.o/' `
if [ "X$GCC" = "Xyes" ] ; then

    CFLAGS="$CFLAGS -O4"
    if [ "$host_cpu" = i486 ] ; then
	    CFLAGS="$CFLAGS -m486"
    fi
    Wall=-Wall
    if [ "$host_os3" = sunos ] ; then
	    Wall=""
    fi
    if [ "$host_os3" = ultrix ] ; then
	    Wall=""
    fi
    if [ "$host_os3" = linux ] ; then
	    CFLAGS="$CFLAGS -fno-strength-reduce"
    fi
    CFLAGS="$CFLAGS $Wall -fomit-frame-pointer"
fi

if [ $host_vendor = linux ] ; then
    CFLAGS="$CFLAGS -DUSE_XDF"
fi


if [ $host_vendor = att ] ; then
    CFLAGS="$CFLAGS -Datt"
fi

if [ $host_os3 = xenix ] ; then
    CFLAGS="$CFLAGS -M2e"
    LDFLAGS="$LDFLAGS -M2e -i -f 5000"
fi

if [ $host_os3 = hpux ] ; then
    LDFLAGS="$LDFLAGS -z"
fi

if [ $host_os2 = sysv4 ] ; then
    SHLIB="-lc -L/usr/ucblib -lucb"
else
    SHLIB=""
fi
]

AC_SUBST(SHLIB)
AC_SUBST(host_cpu)
AC_SUBST(HOST_ID)
AC_OUTPUT(Makefile)
